package com.cy.pj.sys.service.impl;

import com.cy.pj.common.web.pojo.Node;
import com.cy.pj.sys.dao.CGBMenuDao;
import com.cy.pj.sys.pojo.CGBMenu;
import com.cy.pj.sys.service.CGBMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = false,
        rollbackFor = Throwable.class, isolation = Isolation.READ_COMMITTED)
@Service
public class CGBMenuServiceImpl implements CGBMenuService {
    @Autowired
    private CGBMenuDao cgbMenuDao;

    @Transactional(readOnly = true)
    @Override
    public List<CGBMenu> selectMenus() {
        return cgbMenuDao.selectMenus();
    }

    @Override
    public int updateMenu(CGBMenu cgbMenu) {
        return cgbMenuDao.updateMenu(cgbMenu);
    }

    @Override
    public int saveMenu(CGBMenu cgbMenu) {
        return cgbMenuDao.insertMenus(cgbMenu);
    }

    @Transactional(readOnly = true)
    @Override
    public CGBMenu findById(Integer id) {
        return cgbMenuDao.selectById(id);
    }

    @Override
    public List<Node> findMenuTrees() {
        return cgbMenuDao.selectMenuTreeNodes();
    }
}
